package main.scala.exec

import java.io.File

import com.typesafe.config.{Config, ConfigFactory}
import main.scala.utils.ZkUtil

object ItemcenterReadOffset {
    var config:Config = null

  def main(args: Array[String]): Unit = {
    if(args.length != 1){
      print("请输入执行程序的配置文件的路径")
      sys.exit(1)
    }
    config = ConfigFactory.parseFile(new File(args(0)))
    val zkUtil = new ZkUtil(config.getString("dependencies.zookeeper.servers"))
    val offsetPath: String = config.getString("dependencies.zookeeper.kafka_offset")
    val groupId: String = config.getString("source.kafka.group.id")
    val topics: String = config.getString("source.kafka.topics")
    println("打印 消费者组：" + groupId + "的偏移量信息")
    for(topic <- topics.split(",").toArray){
      val fromOffset: List[(String, Int, Long)] = zkUtil.getFromOffsetTuple(offsetPath, groupId, topic)
      for(elem <- fromOffset){
        println("topic:"+elem._1 +"\t"+"partition:"+elem._2+"\t"+"offset:"+elem._3)
      }
    }
  }
}
